import { getCookie } from "./cookie.utils";

export default function loginCheck(store) {
    console.log(store)
    let token = getCookie("token")
    if (token == null) {
        return false;
    }
    else {
        console.log(store.state.user)
        if (store.state.user != null) {
            return true;
        }
        let user = getCookie('user')
        try {
            user = JSON.parse(user)
            console.log(user)
            store.commit("updateUser", user)
            store.commit("updateToken", token)
            return true;
        } catch (e) {
            console.log(e)
            return false;
        }

    }
}